Skip to content

Conversation

@ovflowd
Copy link
Member

@ovflowd ovflowd commented Oct 11, 2025

This PR is a draft PR for upgrading to Next.js 16.

  • Development Server Works
  • Production Build fails
❯ pnpm build

> @node-core/website@ prebuild /home/cwunder/GitHub/nodejs.org/apps/site
> node --run build:blog-data


> @node-core/website@ build /home/cwunder/GitHub/nodejs.org/apps/site
> node --run build:default -- --turbopack

   ▲ Next.js 16.0.0-beta.0 (Turbopack)
   - Experiments (use with caution):
     ✓ globalNotFound
     · optimizePackageImports
     ✓ parallelServerBuildTraces
     ✓ parallelServerCompiles
     ✓ turbopackFileSystemCacheForDev
     ✓ webpackBuildWorker

   Creating an optimized production build ...
 ✓ Compiled successfully in 5.1s
   Skipping validation of types
 ✓ Collecting page data in 654ms    
Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
Error [PageNotFoundError]: Cannot find module for page: /_document
    at ignore-listed frames {
  code: 'ENOENT'
}
Export encountered an error on /_error: /404, exiting the build.
 ⨯ Next.js build worker exited with code: 1 and signal: null
 ELIFECYCLE  Command failed with exit code 1.

@vercel
Copy link

vercel bot commented Oct 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
nodejs-org Ready Ready Preview Nov 14, 2025 4:22pm

@codecov
Copy link

codecov bot commented Oct 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.33%. Comparing base (4c1a417) to head (f14629a).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8218      +/-   ##
==========================================
- Coverage   76.77%   75.33%   -1.44%     
==========================================
  Files         118      118              
  Lines        9828     9836       +8     
  Branches      336      332       -4     
==========================================
- Hits         7545     7410     -135     
- Misses       2281     2424     +143     
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ovflowd
Copy link
Member Author

ovflowd commented Oct 12, 2025

cc @styfle any idea what the prod build failing could be? Pretty much using standard error pages 🤔

@icyJoseph
Copy link
Contributor

icyJoseph commented Oct 14, 2025

Hi, I haven't fully sorted this out, but I managed to get a "bad" passing build. This was my only attempt and the order of steps was a bit chaotic, so not as linearly as presented here.

I used the --debug-prerender flag on next build, and followed the trace from there.

With that flag I started to see:

Error occurred prerendering page "/_not-found". Read more: https://nextjs.org/docs/messages/prerender-error
@node-core/website:build: Error: 
@node-core/website:build:     at WithNavBar (turbopack:///[project]/apps/site/components/withNavBar.tsx:43:31)
@node-core/website:build:   41 |   const { resolvedTheme, setTheme } = useTheme();
@node-core/website:build:   42 |   const { replace } = useRouter();
@node-core/website:build: > 43 |   const pathname = usePathname();
@node-core/website:build:      |                               ^

All of the errors reported, pointed at the group of next-intl helpers, Link, usePathname, useRouter from app/site/navigation.mjs - note that I am not claiming a bug on next-intl.

useLocale and useTranslations were also lifted by --debug-prerender.

After replacing the helpers with their original Next.js version, and replacing useLocale() with a string and useTranslations with a dummy function. I hit one more error, /pages somehow requiring _document to be present. To get around this, I renamed the folder pages to _pages and then edited next.dynamic.mjs file to read from _pages:

 const websitePages = await getMarkdownFiles(
    process.cwd(),
    `_pages/${defaultLocale.code}`
  );

With all of that...

Screenshot 2025-10-13 at 22 55 00

I think the path generation is somehow causing all of these to error. At this point, I do not think that we need to change pages to _pages necessarily. It is just a coincident I believe.

Also I am not familiar enough with this repo, so maybe I am building with the wrong .envs.

Note that https://github.com/amannn/next-intl/tree/main/examples/example-app-router w/ next@beta builds without errors too.

Hopefully this gives you some insight. Happy to keep on helping!

@ovflowd
Copy link
Member Author

ovflowd commented Oct 14, 2025

I think the path generation is somehow causing all of these to error. At this point, I do not think that we need to change pages to _pages necessarily. It is just a coincident I believe.

Sounds like a bug on Next.js imo

All of the errors reported, pointed at the group of next-intl helpers, Link, usePathname, useRouter from app/site/navigation.mjs - note that I am not claiming a bug on next-intl.

Could be that next-intl needs to upgrade to be compatible with Next.js 16? cc @amannn

@icyJoseph
Copy link
Contributor

Most likely a Next.js thing yeah ~ I'll try to set some time apart later, to try and build by bisecting canaries.

@amannn
Copy link
Contributor

amannn commented Oct 14, 2025

Hey @ovflowd, thanks for pinging me! So yes, as @icyJoseph mentioned, the examples in the next-intl repo all worked flawlessly with the beta without modification. I'll only rename the middleware.ts files to proxy.ts in amannn/next-intl#2054.

The only change I found in Next.js 16 beta that broke something for me was related to parallel routes (see vercel/next.js#84738), but a potential solution was discussed in that thread.

I'll make a note to take a closer look at this PR tomorrow, maybe I can spot something! I'll keep you posted.

@icyJoseph
Copy link
Contributor

icyJoseph commented Oct 14, 2025

Hello again!

Could someone verify this, I've been doing some canary bisecting and such, and figured out a couple of things.

Building with --webpack, and removing global-not-found.tsx, passes the build. Right?

Building with --turbopack, removing global-not-found.tsx and mving pages to says _pages, passes the build (who knows what other things go wrong). Right?

Edit: I am confident I've found the source of the bug, I just don't understand global-not-found's role on it, just yet, aka, I can reproduce the bug locally but global-not-found is not part of that just yet.

@icyJoseph
Copy link
Contributor

@amannn sorry for the tag mate, but the mystery is nearly solved.

The global-not-found file on this PR, uses GlowingBackdrop, which in turn uses WithNavBar. The WithNavBar component invokes useSiteNavigation -> useTranslations from next-intl. I guess, it is expected to crash in this scenario? Given the component tree seen from global-not-found?

If we can sort this one out, then --webpack will builds, and we'll likely have a follow up patch to fix --turbopack.

@icyJoseph
Copy link
Contributor

icyJoseph commented Oct 14, 2025

Got the solution :)

global-not-found is missing <NextIntlClientProvider> - https://next-intl.dev/docs/environments/server-client-components#missing-context

Then --webpack builds will work. There's a bug when --turbopack attempts to not generate any Pages Router files (/_error, /500, etc), if it doesn't detect valid Pages Router pages, but this repo setup triggers a bad branch in the code. We are working on a patch for that.

@avivkeller
Copy link
Member

this repo setup triggers a bad branch in the code. We are working on a patch for that.

We are always happy to bug test dependencies 😃, betas are important!

Thank you!

@ovflowd
Copy link
Member Author

ovflowd commented Oct 14, 2025

Got the solution :)

global-not-found is missing <NextIntlClientProvider> - next-intl.dev/docs/environments/server-client-components#missing-context

Then --webpack builds will work. There's a bug when --turbopack attempts to not generate any Pages Router files (/_error, /500, etc), if it doesn't detect valid Pages Router pages, but this repo setup triggers a bad branch in the code. We are working on a patch for that.

Weird thing is Turbopack builds were working with Next.js 15 🤔

@ovflowd
Copy link
Member Author

ovflowd commented Oct 14, 2025

I also found something interesting when creating a pages/404.tsx and a pages/500.tsx and deleting the ones from App Router, it gives this:

> Build error occurred
Error: Turbopack build failed with 1 errors:
./apps/site
App Router and Pages Router both match path: /_not-found
Next.js does not support having both App Router and Pages Router routes matching the same path. Please remove one of the conflicting routes.

Something is clearly bugged/borked on Next.js

@icyJoseph
Copy link
Contributor

Weird thing is Turbopack builds were working with Next.js 15

Right, in one of the canaries going up to v16, a Turbopack optimization was introduced, where some Pages Router assets are no longer generated, if there's no Pages Router code. How "no Pages Router code" is calculated has a bad branch.

Hopefully a patch will be out soon 🙏

@ovflowd
Copy link
Member Author

ovflowd commented Oct 14, 2025

I was able to make it work with a very interesting work around. Creating a 404.tsx and 500.tsx, which kinda explains what you just said.

@ovflowd ovflowd added the github_actions:pull-request Trigger Pull Request Checks label Oct 14, 2025
@ovflowd ovflowd marked this pull request as ready for review October 14, 2025 23:16
@ovflowd ovflowd requested a review from a team as a code owner October 14, 2025 23:16
Copilot AI review requested due to automatic review settings October 14, 2025 23:16
@ovflowd ovflowd requested a review from a team as a code owner October 14, 2025 23:16
@github-actions github-actions bot removed the github_actions:pull-request Trigger Pull Request Checks label Oct 14, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR upgrades the Next.js framework from version 15.5.4 to 16.0.0-beta.0, bringing support for React 19 and introducing the React Compiler. The upgrade includes configuration changes to support new features and fixes for build issues.

Key changes:

  • Upgraded Next.js to version 16.0.0-beta.0 with React Compiler enabled
  • Added placeholder error pages (404.tsx and 500.tsx) and updated error handling components
  • Migrated from Turbo to Turbopack for build optimization and updated TypeScript JSX configuration

Reviewed Changes

Copilot reviewed 13 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pnpm-workspace.yaml Updated @types/react version for React 19 compatibility
package.json Updated cross-env and globals dependencies
apps/site/tsconfig.json Changed JSX transform and added dev types path
apps/site/pages/500.tsx Added placeholder 500 error page
apps/site/pages/404.tsx Added placeholder 404 error page
apps/site/package.json Upgraded Next.js and related packages, added React Compiler
apps/site/next.config.mjs Enabled React Compiler and Turbopack configurations
apps/site/mdx/plugins.mjs Optimized Shiki plugin as singleton for performance
apps/site/eslint.config.js Updated ESLint Next.js configuration format
apps/site/app/global-error.tsx Removed global error page component
apps/site/app/[locale]/not-found.tsx Converted to server component and simplified UI
apps/site/app/[locale]/error.tsx Simplified error page UI and removed arrow icon
.prettierignore Added next-env.d.ts to ignore list
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 14, 2025

Lighthouse Results

URL Performance Accessibility Best Practices SEO Report
/en 🟢 98 🟠 88 🟢 100 🟢 100 🔗
/en/about 🟢 100 🟢 93 🟢 100 🟠 88 🔗
/en/about/previous-releases 🟢 98 🟢 93 🟢 100 🟢 100 🔗
/en/download 🟢 97 🟢 96 🟢 100 🟢 100 🔗
/en/download/archive/current 🟢 99 🟢 100 🟢 100 🟢 100 🔗
/en/blog 🟢 100 🟢 100 🟢 96 🟢 100 🔗

@ovflowd
Copy link
Member Author

ovflowd commented Oct 14, 2025

(Although this is just a workaround and it also creates a /500 and /404 route that are empty pages LOL)

@icyJoseph
Copy link
Contributor

@ovflowd we have an open draft PR to fix it - getting it ready is next on the list! 🙏

@icyJoseph
Copy link
Contributor

icyJoseph commented Oct 29, 2025

Fix is merged: vercel/next.js#84873 - I verified by installing Next.js built using the commit when this PR got merged, and this branch builds without the 400/500 pages patch.

It should be available in the next patch, 16.0.2 (16.0.1 went out before this got merged)

@ovflowd
Copy link
Member Author

ovflowd commented Oct 30, 2025

Awesome! I'll keep an eye on 16.0.2, what's the ETA for it? Be released next week?

@ovflowd
Copy link
Member Author

ovflowd commented Nov 14, 2025

This can get merged. Eventually we can move to proxy.ts once this gets resolved upstream: vercel/next.js#86122

@ovflowd
Copy link
Member Author

ovflowd commented Nov 14, 2025

cc @nodejs/web-infra for a new review

@github-actions github-actions bot removed the github_actions:pull-request Trigger Pull Request Checks label Nov 14, 2025
@avivkeller avivkeller added the github_actions:pull-request Trigger Pull Request Checks label Nov 16, 2025
@github-actions github-actions bot removed the github_actions:pull-request Trigger Pull Request Checks label Nov 16, 2025
@avivkeller avivkeller requested a review from Copilot November 16, 2025 20:55
Copilot finished reviewing on behalf of avivkeller November 16, 2025 20:57
Comment on lines +355 to 362
{
"source": "/404",
"destination": "/"
},
{
"source": "/500",
"destination": "/"
}
Copy link
Member

@avivkeller avivkeller Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of having redirects on these error pages.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated 8 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsx": "react-jsx",
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSX compiler option has been changed from "preserve" to "react-jsx". This change affects how JSX is transformed:

  • "preserve" keeps JSX as-is for Next.js to handle
  • "react-jsx" uses the automatic JSX runtime

While "react-jsx" is generally correct for React 17+, Next.js typically expects "preserve" so it can handle JSX transformation itself. This might cause build issues or unexpected behavior. Verify this change is necessary for Next.js 16, or consider reverting to "preserve".

Suggested change
"jsx": "react-jsx",
"jsx": "preserve",

Copilot uses AI. Check for mistakes.
"mdast-util-to-string": "^4.0.0",
"next": "15.5.4",
"next-intl": "~4.3.11",
"next": "16.0.3",
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is upgrading to [email protected], which appears to be a beta version (the PR description shows "Next.js 16.0.0-beta.0" in the build output). Using beta versions in production is risky as they may contain bugs or breaking changes. Consider:

  1. Waiting for a stable Next.js 16 release
  2. Thoroughly testing all functionality with this beta version
  3. Documenting known issues and limitations
  4. Having a rollback plan ready

Note: The build error shown in the PR description (Error [PageNotFoundError]: Cannot find module for page: /_document) suggests there may be breaking changes in error page handling that need to be addressed.

Suggested change
"next": "16.0.3",
"next": "16.0.0",

Copilot uses AI. Check for mistakes.
Comment on lines +355 to 362
{
"source": "/404",
"destination": "/"
},
{
"source": "/500",
"destination": "/"
}
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding redirects for /404 and /500 to / may not be the correct solution for the build error mentioned in the PR description. These status codes are typically meant to display error pages, not redirect to the homepage. This could mask actual 404/500 errors in production. Consider instead:

  1. Keeping proper 404 and 500 error pages
  2. Investigating why Next.js 16 is having issues with the _document module
  3. Checking if there are migration steps specific to error handling in Next.js 16
Suggested change
{
"source": "/404",
"destination": "/"
},
{
"source": "/500",
"destination": "/"
}

Copilot uses AI. Check for mistakes.
// as we already check it on the CI within each Pull Request
// we also configure ESLint to run its lint checking on all files
eslint: { ignoreDuringBuilds: true },
// Experimental Flags
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ESLint configuration section and its comment have been removed entirely. This removes the eslint: { ignoreDuringBuilds: true } setting. Without this, ESLint will now run during production builds, which may cause build failures if there are any linting errors. Consider either:

  1. Keeping eslint: { ignoreDuringBuilds: true } if you still want to skip ESLint during builds
  2. Ensuring all ESLint errors are fixed before merging
  3. Documenting this intentional change if the goal is to enforce linting during builds

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants